﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using NuGet.Enterprise.Server.Configuration;

namespace NuGet.Enterprise.Server.Models.Feeds
{
    public class FeedProvider
        : IFeedProvider
    {
        public IFeed GetFeed(string name)
        {
            var settings = BuildStoreSection.Current.Connections[name];

            return settings == null
                       ? null
                       : new Feed()
                         {
                             Name = settings.Name,
                             DisplayName = settings.DisplayName
                         };
        }

        public IEnumerable<string> Feeds
        {
            get { return BuildStoreSection.Current.Connections.Select(settings => settings.Name); }
        }
    }
}